home *** CD-ROM | disk | FTP | other *** search
- /*
- File: Exceptions.h
-
- Contains: exception handling macros
- Brutally stolen from the Finder 7.1 sources
- Brutally restolen from the Star Trek runtime stuff
-
- Written by: Bruce Horn, Steve Capps, Larry Kenyon,
- John Meier, scott douglass, Darin Adler,
- Paul Mercer, Bryan Stearns, Dave Owens, Alan Mimms
-
- Copyright: © 1988-1990, 1993 by Apple Computer, Inc., all rights reserved.
-
- Change History (most recent first):
-
- <1> 10/11/93 DRF Miss Manners + MW mangling
- <1> 6/15/93 ABM first checked in
- <4> 12/3/92 dho reinclude CDStackFrame* back into our TException class
- <3> 9/30/92 dho move exceptions data out of partition globals
- <2> 9/15/92 dho make include quoting exact
- <2+> 8/27/92 dho 8.3
- <2> 8/17/92 dho use setJmp and longJmp for exception handling
- <1> 7/24/92 dho First checked in for Star Trek
- <3+> 3/27/90 sad guard #includes
- 12/15/89 sad suppress value no used warning from NOREGISTER
- 10/2/89 sad add extern "C"; add savedCDStackPtr to exceptions_tFailInfo;
- added exceptions_FailAgain
- 4/29/89 BJS add NOREGISTER
- 9/11/88 JRM incluse moretypes
- 9/10/88 dba add FailAgain and ExpectError macros
- 8/29/88 dba added Fail
- 8/19/88 dba added FailMemError, FailResError, and FailResourceNil
- 7/21/88 JRM add FailErr and FailNil
- 7/15/88 JRM received version from Andy Heninger
- 7/5/88 AH Revise to work with plain C as well as C++
- 6/27/88 AH Initial Version
-
- To Do:
- */
-
- #ifndef _EXCEPTIONS_
- #define _EXCEPTIONS_
-
- #include <Types.h>
- #include <setjmp.h>
-
-
- class TException
- {
- public:
- TException();
- ~TException();
-
- void Pop(void);
-
- jmp_buf fEnv;
- TException * fNext;
- };
-
-
- void Fail(void);
-
- inline void FailIf (int cond)
- {
- if (cond) Fail();
- }
-
- inline void FailNil(void *p)
- {
- if (p == nil)
- Fail();
- }
-
- #define TRY { TException exceptionData; if (setjmp(exceptionData.fEnv) == 0) {
- #define EXCEPT } else {
- #define ENDTRY } exceptionData.Pop(); }
-
-
- #endif
-